function animate(obj, target, callback) {
  clearInterval(obj.timer);
  obj.timer = setInterval(() => {
    if (obj.offsetLeft == target) {
      clearInterval(obj.timer);
      // 判断函数是否存在
      if (callback != null) {
        callback();
      }
      return;
    }
    // 步长 = (目标距离 - 当前距离) / 10
    var step = (target - obj.offsetLeft) / 10;
    step = step > 0 ? Math.ceil(step) : Math.floor(step);
    obj.style.left = obj.offsetLeft + step + "px";
  }, 20);
}
